#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, traceback, Ice
Ice.loadSlice('MotorGrid.ice', ['-I' '/usr/share/slice'])
import Demo

class AMI_Model_interpolarI(object):
    def ice_response(self, resultado):
        print 'Datos recibidos.'
        # Procesamiento de datos.
        print resultado

    def ice_exception(self, ex):
        try:
            raise ex
        except Demo.ErrorDeRango, e:
            print "Error al interpolar: Error de rango."
        except Ice.LocalException, e:
            print "Error al interpolar: " + str(e)

class Client (Ice.Application):
    def run (self, argv):
        self.shutdownOnInterrupt()
        basePrx = self.communicator().stringToProxy('MotorGrid:default -p 10000')
        modelPrx = Demo.ModelPrx.checkedCast(basePrx)
        cb = AMI_Model_interpolarI()
        grid = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
        modelPrx.interpolar_async(cb, grid, 0.5)
        self.communicator().waitForShutdown()
        return 0

Client().main(sys.argv)
